import request from "../utils/network"
import http from '@ohos.net.http'

const USER_BASE_URL: string = "/user"

export function login(data): Promise<Object> {
  return request({
    url: "/login",
    method: http.RequestMethod.POST,
    data: data
  })
}

export function getUserInfo(): Promise<Object> {
  return request({
    url: USER_BASE_URL + '/info',
    method: http.RequestMethod.GET,
    data: {}
  })
}

export function getUserAll(): Promise<Object> {
  return request({
    url: USER_BASE_URL + '/all',
    method: http.RequestMethod.GET,
    data: ""
  })
}

export function updateUserNickName(userNickName: string): Promise<Object> {
  return request({
    url: USER_BASE_URL + "/update/" + encodeURIComponent(userNickName),
    method: http.RequestMethod.POST,
    data: ""
  })
}